/*
 * This file is part of ksPlatform
 * 
 * Copyright (c) 2014-2015
 * 
 * This file is dual-licensed under the AGPLv3 (http://www.gnu.org/licenses/agpl-3.0.html) 
 * 
 * If you are unsure which license is appropriate for your use, please contact the sales department
 * at 97041437@qq.com.
 */
package cn.com.ksplatform.modules.autocode.sdk.v1.controller;

import java.lang.reflect.InvocationTargetException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.com.ksplatform.core.context.PlatformContext;

/**
 * ClassName:SdkController.java <br/>
 * Date: 2015年12月28日 <br/>
 * Sdk控制器 
 * @author Mr.Xiao
 * @version 1.0
 */
@Controller
@RequestMapping("/modules/autocode/sdk")
public class SdkController {
	
	private String header = "autocode.sdk.";
	
	@RequestMapping("/{component}/{fun}")
	@ResponseBody
	public Object service(@PathVariable String component,@PathVariable String fun,HttpServletRequest req , HttpServletResponse rep) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException{
		Object comp = PlatformContext.getBean(header+component);
		return comp.getClass().getMethod(fun,HttpServletRequest.class,HttpServletResponse.class).invoke(comp, req, rep);
	}
}